#include "Factory.h"
#include "GameObject.h"
#include "Components/Transform.h"
#include "Components/SceneNode.h"
#include "Components/AI.h"
#include "Components/Vehicle.h"
#include "Components/TaskPerformer.h"


//#include "ECS/Dependency.h"
//
//class MyComponent : public ECS::Dependent<AI>
//{
//
//};
//
//class OtherComponent : public ECS::Dependent2<Vehicle, TaskPerformer>
//{
//
//};

GameObject* Factory::createUnit( int x, int y )
{
	GameObject* go = new GameObject();
	auto transform		= go->createComponent<Transform>();
	auto sceneNode		= go->createComponent<SimpleSceneNode>();
	auto vehicle		= go->createComponent<Vehicle>();
	auto taskPerformer	= go->createComponent<TaskPerformer>();
	auto ai				= go->createComponent<AI>();

	sceneNode->meshName = "ninja.mesh";
	go->start();
	transform->setPosition(Vector2((float)x, (float)y));
	sceneNode->setNodeScale(0.4f);
	IntPoint path[] = {IntPoint(x + 1, y + 1), IntPoint(x + 2, y + 1), IntPoint(x + 2, y + 2), IntPoint(x + 3, y + 2), IntPoint(x + 3, y + 1)};
	vehicle->setPath(5, path);
	return go;
}

GameObject* Factory::createTree( int x, int y )
{
	GameObject* go = new GameObject();
	auto transform		= go->createComponent<Transform>();
	auto sceneNode		= go->createComponent<SimpleSceneNode>();
	sceneNode->meshName = "tree2Billboard20.mesh";
	go->start();
	transform->setPosition(Vector2((float)x, (float)y));
	return go;
}

GameObject* Factory::createGold( int x, int y )
{
	GameObject* go = new GameObject();
	auto transform		= go->createComponent<Transform>();
	auto sceneNode		= go->createComponent<SimpleSceneNode>();
	sceneNode->meshName = "barell.mesh";
	go->start();
	transform->setPosition(Vector2((float)x, (float)y));
	return go;
}

GameObject* Factory::createStone( int x, int y )
{
	GameObject* go = new GameObject();
	auto transform		= go->createComponent<Transform>();
	auto sceneNode		= go->createComponent<SimpleSceneNode>();
	sceneNode->meshName = "barell.mesh";
	go->start();
	transform->setPosition(Vector2((float)x, (float)y));
	return go;
}

void Factory::registerMetatables()
{
	Transform::_metaTable();
	SceneNode::_metaTable();
	SimpleSceneNode::_metaTable();
	GameObject::_metaTable();
	AI::_metaTable();
	TaskPerformer::_metaTable();

}
